package org.ax.controller.process;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.ax.data.Result;
import org.ax.pojo.process.Process;
import org.ax.pojo.process.TechnologyRequirement;
import org.ax.service.process.ProcessService;
import org.ax.service.process.TechnologyRequirementService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

/**
 * 编程人:赵浩鑫
 * 时间:2021-02-28-21:01
 */
@RestController
@RequestMapping("/process")
public class ProcessController {
    @RequestMapping("/find")
    public ModelAndView find(){
        return new ModelAndView("process/process");
    }
    @Autowired
    ProcessService processService;
    @Autowired
    Result result;
    @GetMapping("/list")
    public Result search(@RequestParam(defaultValue = "1") int page, @RequestParam(defaultValue = "6") int limit){
        Page<Process> processPage = processService.searchProcessPage(new Page(page, limit));
        result.setData(processPage.getRecords());
        result.setCount(processPage.getTotal());
        return result;
    }
    @PostMapping("/add")
    public Result addProduct(Process process){
        result.setMsg(processService.addProcess(process)?"添加成功":"添加失败");
        return result;

    }
    @PostMapping("/update")
    public Result updateProduct(Process process){
        result.setMsg(processService.updateProcess(process)?"修改成功":"修改失败");
        return result;

    }
    @GetMapping("/patchDel")
    public Result patchDel(String[] ids){
        result.setMsg(processService.deletesProcess(ids)?"批量删除成功":"批量删除失败");
        return result;
    }
    @GetMapping("/processList")
    public Result processList(){
        result.setData(processService.availableProcess());
        return result;
    }
}
